<!-- xml version="1.0" encoding="utf-8" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	<title>Ilias</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<link href="../classics.css" rel="stylesheet" type="text/css">
</head>
<?php


try {
	$db = new PDO('sqlite:Ilias.db3');
	$q = $db->query('SELECT DISTINCT book, max(line) FROM vocabulary ORDER BY book;');
	$books = array();
	foreach( $q->fetchAll() as $row) {
		$books[$row['book']] = $row['max(line)'];
	}

	$db = NULL;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}

?>


<body>

<h1 align="center">Vocabulary</h1>
<div id="container">
<div id="center">
<form name="v01" action="VocFlash.php" method="post">
<table align="center">

<?php
$j = 0;
foreach($books as $book => $mline) {
	print "<tr><th colspan=10 class=\"separate-above\">ΙΛΙΑΔΟΣ $book</th></tr>\n";
	print "<tr>";
	for($n = 5; $n <= ceil($mline/5) * 5; $n += 5) {
		$line = $n <= $mline ? $n : $mline;
		print "<td><input type=\"checkbox\" name=\"lines[]\" value=\"$book.$line\" />$line</td>";
		$j++;
		if (! ($j % 10)) {
			print "</tr>\n<tr>";
		}
	}
	print "</tr>\n";
}
?>
<tr class="separate-above">
	<td align="center" colspan=10><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</div>
</div>

</body>
</html>
